package com.mmg.spzx.user.controller;

import com.mmg.spzx.model.entity.base.Region;
import com.mmg.spzx.model.vo.common.Result;
import com.mmg.spzx.model.vo.common.ResultCodeEnum;
import com.mmg.spzx.user.service.UserRegionService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name = "用户地区接口")
@RestController
@RequestMapping(value = "/api/user/region")
public class UserRegionController {

    @Autowired
    private UserRegionService userRegionService;

    @Operation(summary = "收货地址省市区显示")
    @GetMapping("/findByParentCode/{code}")
    public Result register(@PathVariable("code") Integer code) {
        List<Region> regionList = userRegionService.selectByParentCode(code);
        return Result.build(regionList, ResultCodeEnum.SUCCESS);
    }
}
